function draw.DrawSimpleRect(x, y, w, h, col)
	surface.SetDrawColor(col);
	surface.DrawRect(x, y, w, h);
end;

function draw.DrawSimpleOutlined(x, y, w, h, col)
	surface.SetDrawColor(col);
	surface.DrawOutlinedRect(x, y, w, h);
end;

function draw.DrawDoubleOutlined(x, y, w, h, col)
	surface.SetDrawColor(col);
	surface.DrawOutlinedRect(x, y, w, h);
	surface.DrawOutlinedRect(x +1, y +1, w -2, h -2);
end;

function draw.DrawTexture(x, y, w, h, color, texture)
	surface.SetDrawColor(color);
	surface.SetTexture(texture);
	surface.DrawTexturedRect(x, y, w, h);
end;

function util.GetTextSize(font, text)
	surface.SetFont(font);
	local w, h = surface.GetTextSize(text);
	
	return w, h;
end;

function util.simpleLabel(parent, title, col, font, x, y)
	local label = nil;
	
	if (parent != nil) then
		label = vgui.Create("DLabel", parent);
	else
		label = vgui.Create("DLabel");
	end;
	
	if (x and y) then
		label:SetPos(x, y);
	end;
	
	if (col) then
		label:SetColor(col);
	end;
	
	label:SetText(title);
	label:SetFont(font);
	label:SizeToContents();
	
	return label;
end;

function util.simpleButton(parent, x, y, w, h, text, disabled, func)
	local DButton = nil;
	
	if (parent != nil) then
		DButton = vgui.Create("DButton", parent);
	else
		DButton = vgui.Create("DButton");
	end;
	
	DButton:SetText(text);
	
	if (w and h) then
		DButton:SetSize(w, h);
	end;
	
	if (x and y) then
		DButton:SetPos(x, y);
	end;
	
	DButton:SetDisabled(disabled);
	DButton.DoClick = func;
	
	return DButton;
end;

local progressBars = {};

function GM:ShouldDrawProgressBars()
	return #progressBars > 0;
end;

function GM:RemoveProgressBar(text)
	for k, v in pairs(progressBars) do
		if (v.text == text) then
			table.remove(progressBars, k);
		end;
	end;
end;

function GM:AddProgressBar(seconds, text)
	table.insert(progressBars, {seconds = seconds, text = text, start = CurTime()});
end;

-- shit code, but it does the job.
function GM:DrawProgressBars()
	if (progressBars[1]) then
		local data = progressBars[1];
		local x1 = ScrW() /2 -100;
		local x1_2 = ScrW() /2;
		
		if (!data.realTime) then
			data.realTime = RealTime();
		end;

		local progress = ((RealTime() -data.realTime) /data.seconds) *188;
		
		draw.SimpleText(data.text, "TargetID", x1_2 +1, ScrH() /2 +1, color_black, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
		draw.SimpleText(data.text, "TargetID", x1_2, ScrH() /2, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
		
		draw.RoundedBox(4, x1, ScrH() /2 +16, 200, 20, Color(0, 0, 0, 190));
		draw.DrawSimpleRect(x1 +1, ScrH() /2 +17, progress, 18, Color(81, 81, 81, 210));
		
		if (data.start +data.seconds < CurTime()) then
			table.remove(progressBars, 1);
		end;
	
		if (progressBars[2]) then
			x1 = 210;
			x1_2 = 300;
			
			local data2 = progressBars[2];
			
			if (!data2.realTime) then
				data2.realTime = RealTime();
			end;
			
			local progress = ((RealTime() -data2.realTime) /data2.seconds) *188;
		
			draw.SimpleText(data2.text, "TargetID", x1_2 +1, ScrH() /2 +1, color_black, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
			draw.SimpleText(data2.text, "TargetID", x1_2, ScrH() /2, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
			
			draw.RoundedBox(4, x1, ScrH() /2 +16, 200, 20, Color(0, 0, 0, 190));
			draw.DrawSimpleRect(x1 +1, ScrH() /2 +17, progress, 18, Color(81, 81, 81, 210));

			if (data2.start +data2.seconds < CurTime()) then
				table.remove(progressBars, 2);
			end;
			
			if (progressBars[3]) then
				x1 = ScrW() /2 +200;
				x1_2 = ScrW() /2 +300;
				
				local data3 = progressBars[3];
				
				if (!data3.realTime) then
					data3.realTime = RealTime();
				end;
				
				local progress = ((RealTime() -data3.realTime) /data3.seconds) *188;
		
				draw.SimpleText(data3.text, "TargetID", x1_2 +1, ScrH() /2 +1, color_black, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
				draw.SimpleText(data3.text, "TargetID", x1_2, ScrH() /2, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER);
				
				draw.RoundedBox(4, x1, ScrH() /2 +16, 200, 20, Color(0, 0, 0, 190));
				draw.DrawSimpleRect(x1 +1, ScrH() /2 +17, progress, 18, Color(81, 81, 81, 210));

				if (data3.start +data3.seconds < CurTime()) then
					table.remove(progressBars, 3);
				end;
			end;
		end;
	end;
end;